package com.txzt.gaea.provide.controller;

import com.txzt.base.core.RtnInfo;
import com.txzt.gaea.common.base.controller.BaseController;
import com.txzt.gaea.common.page.PageInfoBT;
import com.txzt.gaea.provide.dto.InformationDeliveryAddDTO;
import com.txzt.gaea.provide.dto.InformationDeliveryQueryDTO;
import com.txzt.gaea.provide.dto.InformationDeliveryUpdateDTO;
import com.txzt.gaea.provide.service.InformationDeliveryService;
import com.txzt.gaea.provide.utils.LogUtils;
import com.txzt.gaea.provide.vo.InformationDeliveryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/informationDelivery")
public class InformationDeliveryController extends BaseController {


    @Autowired
    private InformationDeliveryService informationDeliveryService;

    /**
     * 查询列表
     */
    @PostMapping(value = "/list")
    public RtnInfo<PageInfoBT<InformationDeliveryVO>> list(@RequestBody InformationDeliveryQueryDTO dto) throws Exception {


        LogUtils.logSave("informationDelivery#list", "查询文件列表", "com.txzt.gaea.provide.controller.InformationDeliveryController");

        return informationDeliveryService.list(dto);
    }

    /**
     * 添加
     */
    @PostMapping(value = "/add")
    public RtnInfo add(@RequestBody InformationDeliveryAddDTO dto) throws Exception {


        LogUtils.logSave("informationDelivery#add", "添加文件", "com.txzt.gaea.provide.controller.InformationDeliveryController");

        if (null == dto || 0 != dto.checkValid().getCode()) {
            return RtnInfo.PARAM_MISSING;
        }
        return RtnInfo.success(informationDeliveryService.add(dto));
    }

    /**
     * 查询详情
     */
    @GetMapping(value = "/detail/{id}")
    public RtnInfo detail(@PathVariable Long id) throws Exception {
        LogUtils.logSave("informationDelivery#detail", "查询文件详情", "com.txzt.gaea.provide.controller.InformationDeliveryController");
        return informationDeliveryService.detail(id);
    }

    /**
     * 更新
     */
    @PostMapping(value = "/update")
    public RtnInfo update(@RequestBody InformationDeliveryUpdateDTO dto) throws Exception {
        LogUtils.logSave("informationDelivery#update", "更新文件", "com.txzt.gaea.provide.controller.InformationDeliveryController");
        if (null == dto || 0 != dto.checkValid().getCode()) {
            return RtnInfo.PARAM_MISSING;
        }
        return RtnInfo.success(informationDeliveryService.update(dto));
    }

    /**
     * 删除数据
     */
    @GetMapping(value = "/del/{id}")
    public RtnInfo del(@PathVariable Long id) throws Exception {
        LogUtils.logSave("informationDelivery#del", "删除文件数据", "com.txzt.gaea.provide.controller.InformationDeliveryController");
        return informationDeliveryService.del(id);
    }
}
